package com.lax.advertmgt.exception;

import org.apache.commons.lang.StringUtils;

public class PlatformException extends Exception {
    private static final long serialVersionUID = 1L;
    private String code;
    private String msg;

    public PlatformException(String message, Throwable cause) {
        super(message, cause);
    }

    public PlatformException(Throwable cause) {
        super(cause);
    }

    public PlatformException(BaseExprInfo exprInfo) {
        this.code = exprInfo.getCode();
        this.msg = exprInfo.getMsg();
    }

    public PlatformException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    protected static String buildMsg(String errMsg, String... paramData) {
        if (StringUtils.isBlank(errMsg)) {
            return "";
        } else {
            if (paramData.length > 0) {
                errMsg = errMsg.replace("{}", " " + paramData[0] + " ");
            } else {
                errMsg = errMsg.replace("{}", " ");
            }

            return errMsg;
        }
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
